<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>订单信息汇总</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js" integrity="sha384-ep+dxp/oz2RKF89ALMPGc7Z89QFa32C8Uv1A3TcEK8sMzXVysblLA3+eJWTzPJzT" crossorigin="anonymous"></script>

</head>
<body>
<div th:replace="fragments/header:: navbar"></div>
<div class="container pt-5">
    <h3 class="text-center">订单信息汇总</h3>
    <div class="alert alert-success" th:if="${successMessage}" th:utext="${successMessage}" ></div>
    <table class="table table-striped table-bordered text-center">
        <thead>
        <tr>
            <th>编号</th>
            <th>日期</th>
            <th>价格</th>
            <th>状态</th>
            <th>用户</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:if="${#lists.isEmpty(orders)}">
            <td colspan="7">订单为空</td>
        </tr>
        <th:block th:each="order:${orders}">
            <tr th:switch="${order.orderStatus}">
                <td>[[${order.orderId}]]</td>
                <td>[[${order.orderDate}]]</td>
                <td>[[${order.orderPrice}]]元</td>
                <td th:case="true"><i class="bi bi-check-lg" aria-hidden="true"></i></td>
                <td th:case="false"><i class="bi bi-clock" aria-hidden="true"></i></td>
                <td><a th:href="@{'/users/edit/{userId}'(userId=${order.user.userId})}">[[${order.user.userName}]]</a></td>
                <td>
                    <a class="btn btn-info" th:href="@{'/order/{orderId}'(orderId=${order.orderId})}">详情</a>
                    <a th:unless="${order.orderStatus}" class="btn btn-warning" th:href="@{'/orders/complete/{orderId}'(orderId=${order.orderId})}">完成</a>
                    <a class="btn btn-danger" th:href="@{'/orders/delete/{orderId}'(orderId=${order.orderId})}">删除</a>
                </td>
            </tr>
        </th:block>
        </tbody>
        <a class="btn btn-primary mb-3" th:href="@{/}">返回首页</a>
    </table>
</div>
</body>
</html>